import time

from selenium.webdriver.common.by import By

from common.Utils import forum


class userInfo:
    driver = ""

    def __init__(self):
        self.url = "http://127.0.0.1:58080/index.html"
        self.driver = forum.driver
        self.driver.get(self.url)

        self.driver.find_element(By.CSS_SELECTOR,"#index_nav_name_sub").click()
        self.driver.find_element(By.CSS_SELECTOR, "#index_user_settings").click()
        time.sleep(2)

    #元素检查
    def InfoCheck(self):

        #昵称
        # #setting_input_nickname
        # #bit-forum-content > div.page-body > div > div > div > div.col.d-flex.flex-column > div > h3:nth-child(4)
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname")
        #邮件
        self.driver.find_element(By.CSS_SELECTOR, "#setting_submit_email")
        #电话
        self.driver.find_element(By.CSS_SELECTOR, "#setting_input_phoneNum")
        #个人简介
        self.driver.find_element(By.CSS_SELECTOR, "#settings_textarea_remark")

        forum.GetScreenShot()
    #修改功能
    def ModifyFun(self):
        #测一：修改昵称（其他以此类推）
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname").clear()
        self.driver.find_element(By.CSS_SELECTOR,"#setting_input_nickname").send_keys("Tom")
        self.driver.find_element(By.CSS_SELECTOR,"#setting_submit_nickname").click()

        #测二：修改密码（正常和异常）
        #正确原密码
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_oldPassword").send_keys("123456")
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_newPassword").send_keys("123")
        self.driver.find_element(By.CSS_SELECTOR,"#settings_input_passwordRepeat").send_keys("123")
        self.driver.find_element(By.CSS_SELECTOR,"#settings_submit_password").click()

